#include <iostream>
#include <cstdlib>
#include <queue>
using namespace std;
/* 
插入结点x到p的左孩子如果p有左孩子那么原来的左孩子作为x的右孩子
 */
typedef struct binode
{
    int data;
    struct binode *lchild;
    struct binode *rchild;
} binode, *bitree;

void sub(bitree &t, binode *p, int x)
{
    // 队列
    queue<bitree> q;
    // 遍历指针
    bitree node;
    if (!t)
    {
        // 空树直接返回
        return;
    }
    q.push(t);
    while (!q.empty())
    {
        node = q.front();
        q.pop();
        if (node->lchild != nullptr)
        {
            q.push(node->lchild);
        }
        if (node->rchild != nullptr)
        {
            q.push(node->rchild);
        }
        if (node == p)
        {
            binode *tmp = new binode;
            tmp->data = x;
            tmp->lchild = nullptr;
            tmp->rchild = nullptr;
            if (node->lchild == nullptr)
            {
                node->lchild = tmp;
            }
            else
            {
                tmp->rchild = node->lchild;
                node->lchild = tmp;
            }
        }
    }
}

int main(int argc, char const *argv[])
{

    return 0;
}
